#include <DTH11_INIT.h>
#include <LCD1602_INIT.h>
#include <UARTINIT.h>


sbit fan = P1^6;
extern char dat[5];
char hum[8];
char tem[8];


void hum_tem(){

	hum[0] = 'H';
	hum[1] = dat[0]/10 + 0x30;
	hum[2] = dat[0]%10 + 0x30; 
	hum[3] = '.';
	hum[4] = dat[1]/10 + 0x30;
	hum[5] = dat[1]%10 + 0x30; 
	hum[6] = '%';
	hum[7] = '\0';
	
	tem[0] = 'T';
	tem[1] = dat[2]/10 + 0x30;
	tem[2] = dat[2]%10 + 0x30; 
	tem[3] = '.';
	tem[4] = dat[3]/10 + 0x30;
	tem[5] = dat[3]%10 + 0x30; 
	tem[6] = 'd';
	tem[7] = '\0';
}


int main(){

	Delay1000ms();
	Delay1000ms();
	Delay1000ms();
	InitUart();
	Init_dht();
	Init_lcd1602();
	
	while(1){
		UART_dht();
		Delay1000ms();
		hum_tem();
		Delay1000ms();
		if(dat[2] >= 30){
			fan = 0;
		}
		if(dat[2] <= 29){
			fan = 1;
		}
		Delay1000ms();
		write_string(1,2,hum);
		write_string(2,2,tem);
		Sendstring(hum);
		Sendstring("\r\n");
		Sendstring(tem);
		Sendstring("\r\n");
	}

}